package cn.lanqiao.service.serviceImpl;

import cn.lanqiao.dao.StudentDao;
import cn.lanqiao.dao.daoImpl.StudentDaoImpl;
import cn.lanqiao.entity.Student;
import cn.lanqiao.service.StudentService;

import java.util.ArrayList;

public class StudentServiceImpl implements StudentService {
    StudentDao sd = (StudentDao) new StudentDaoImpl();
//查询所有学生
    @Override
    public int addStudent(Student s) {
        return sd.addStudent(s);
    }
    @Override
    public ArrayList<Student> queryAllStudent() {
        return sd.queryAllStudent();
    }
//按照id查询
    @Override
    public Student queryStudentById(int student_id) {
        //按照学号id查询出学生
        Student student = sd.quertStudentById(student_id);
        //把对象返回出去
        return student;
    }
//增加学生
    @Override
    public int updateStudentInfo(Student student) {
        return sd.updateStudentInfo(student);
    }
//删除学生
    @Override
    public int deleteStudent(int student_id) {
        return sd.deleteStudent(student_id);
    }
//分页查询
    @Override
    public ArrayList<Student> queryStudentBypage(int pageNum, int pageSize) {
        return sd.queryStudentBypage(pageNum,pageSize);
    }
//排序功能
    @Override
    public ArrayList<Student> orderAllStudent() {
        return sd.orderAllStudent();
    }
//统计功能
    @Override
    public double maleToFemaleRatio() {
        int maleCount = maleStudents();
        int femaleCount = femaleStudents();
        return (double) maleCount / femaleCount;
    }

    @Override
    public int totalStudents() {
        return sd.totalStudents();
    }

    @Override
    public int femaleStudents() {
        return sd.femaleStudents();
    }

    @Override
    public int maleStudents() {
        return sd.maleStudents();
    }

    @Override
    public void batchAddStudentsService(ArrayList<Student> students) {
         sd.batchAddStudents(students);
    }

    @Override
    public void batchDeleteStudentsService(ArrayList<Integer> student_id) {
         sd.batchDeleteStudents(student_id);
    }


}
